<template>
    <div>
    {{this.openid}}
    </div>
</template>

<script>
import util from "@/utils/";
import { getList } from "@/api/wechat";
import { checkmember } from "@/api/member";

export default {
  data() {
    return {
      openid: "",
      mobile: "",
      form: {
        opid: "",
        headpic: "",
        mobile: ""
      },
      webUrl: "http://www.since80.com"
    };
  },
  created() {
    // 检测会员有没有登录
    if (!util.cookie.get("GBPUser")) {
      let ua = window.navigator.userAgent.toLowerCase();

      this.openid = this.$route.query.openid;
      this.form.opid = this.$route.query.openid;
      this.form.headpic = this.$route.query.headpic;

      if (!this.openid) {
        window.location.href = "http://www.baidu.com";
      }

      util.cookie.set("openid",this.openid)
      util.cookie.set("headpic",this.form.headpic)
      this.checkopid();
      // if(ua.match(/MicroMessenger/i) == 'micromessenger'){
      //   // 跳转到微信授权页面
      //   console.log('11111')

      //   //window.location.href = this.webUrl + '/Wap/User/getOpenid'
      // }

      // window.location.href = 'http://www.sina.com'
    } else {
      // 如果有token 但是vuex中没有用户登录信息则做登录操作
      // window.location.href = 'http://www.baidu.com'

      console.log("8888");
    }
  },
  methods: {
    checkopid() {
      let res = false;
      checkmember(this.form).then(response => {
        res = response.data.result;
        //console.log(res);
        if(res)
        {
          this.$router.push({ name: 'login'})
        }else{
          window.location.href = 'http://www.sina.com.cn'
        }

        //console.log("已注册用户，跳转至首页");
      });
    }
  }
};
</script>
